package com.info.game;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.component.game.PhysicsComponent;
import com.engine.game.GameObject;

public class FloorStage1PhysicsComponent implements PhysicsComponent{

	private Body floor;
	
	
	@Override
	public void dispose() {
		
		this.floor.getWorld().destroyBody(this.floor);
		
		
	}

	@Override
	public void bodyCreation(GameObject object) {
		
		BodyDef floorDef = new BodyDef();
		floorDef.type = BodyType.StaticBody;
		floorDef.position.set(20, 0);
		
		this.floor = object.getPhysicsWorld().createBody(floorDef);
		
		PolygonShape floorShape = new PolygonShape();
		floorShape.setAsBox(SizeOfThings.Stage1FloorWidth/2, SizeOfThings.Stage1FloorHeight/2);
		
		FixtureDef floorFix = new FixtureDef();
		floorFix.shape = floorShape;
		
		
		
		this.floor.createFixture(floorFix).setUserData(object.name);;
		
		
		
		this.floor.setUserData(object);
		
		
		
		
	}

	@Override
	public void update(GameObject object) throws InstantiationException,
			IllegalAccessException, ClassNotFoundException {
		
		
	}

	
	
	
	
	
	@Override
	public void collisionWith(GameObject me, String enemy) {
		
		
	}

	@Override
	public void endCollisionWith(GameObject me, String enemy) {
		
		
	}

	@Override
	public float getCenterBodyX() {
		
		return this.floor.getPosition().x;
	}

	@Override
	public float getCenterBodyY() {
		
		return this.floor.getPosition().y;
	}

	@Override
	public float getBodyAngle() {
		
		return this.floor.getAngle() * MathUtils.radiansToDegrees;
	}

}
